<template>
  <div>
    <div class="modelbox">
      <div class="modexboxcontent">
      </div>
    </div>
    <div class="flex justify-center items-center" v-if="false">
      <div class="mask"></div>
      <div v-if="!showmodalremark" class="tbagestyle">
        <div class="gbstyel" @click="close()"></div>
        <div class="lbform">
          <div>手机号: <input type="number" v-model="popform.telphone"></div>
          <div class="mt-1">
            验证码: <input class="codestyle" type="number" v-model="popform.code">
            <span v-if="showtext" class="sendcode" @click="sendCode">发送验证码</span>
            <span v-if="!showtext" class="codenumber">剩余{{ miaonum }}秒</span>
          </div>
          <div class="gbsbutbox w-full flex justify-center mt-1">
            <div class="gbsbut2 " @click="submit()"></div>
          </div>
        </div>
      </div>
      <div v-if="showmodalremark" class="yusuccessmodal">
        <div class="gbstyelsec" @click="close()"></div>
      </div>
    </div>
  </div>
</template>

<script>
import qs from "qs";
export default {
  name: 'yyPop',
  data() {
    return {
      // 预约表单
      popform: {
        telphone: '',
        code: ''
      },
      showtext: true,
      miaonum: 59,
      timer: null,
      showmodalremark: false
    }
  },
  components: {},
  methods: {
    sendCode() {
      if (this.popform.telphone) {
        this.axios({
          method: "post",
          url: 'https://gameapi.nextjoy.com/appointment/sendCode',
          data: qs.stringify({
            pubkey: '48a3e38773709ee451b971ce5d517da5',
            mobile: this.popform.telphone
          })
        }).then(res => {
          if (res.data.status != '200') {
            alert(res.data.message)
          } else {
            this.showtext = false
            if (this.timer) clearInterval(this.timer)
            this.timer = setInterval(() => {
              this.miaonum -= 1;
              if (this.miaonum === 0) {
                this.showtext = true;
                if (this.timer) clearInterval(this.timer)
                this.miaonum = 59;
              }
            }, 1000);
          }
        })
      } else {
        alert('请输入手机号')
      }
    },
    submit() {
      if (this.popform.code) {
        this.axios({
          method: "post",
          url: 'https://gameapi.nextjoy.com/appointment/appoint',
          data: qs.stringify({
            pubkey: '48a3e38773709ee451b971ce5d517da5',
            mobile: this.popform.telphone,
            from_type: 1,
            code: this.popform.code
          })
        }).then(res => {
          console.log(res)
          console.log(this.popform.telphone, this.popform.code)
          this.showmodalremark = true
        })
      } else {
        alert('验证码不能为空')
      }
      if (!this.popform.telphone) {
        alert('手机号不能为空')
      }
    },
    close() {
      this.popform.telphone = ''
      this.popform.code = ''
      this.$emit('onClose')
    },

  }
}
</script>

<style scoped>
/* 弹框代码 */
.modelbox {
  position: fixed;
  left: 0px;
  top: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1040;
  background-color: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(15px);

}

.modexboxcontent {
  position: absolute;
  color: #fff;
  z-index: 1041;
}

input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  -webkit-appearance: none !important;
  margin: 0;
}

/* 火狐 */
input[type="number"] {
  -moz-appearance: textfield;
}

.lbform {
  margin: 0 auto;
  margin-left: 2rem;
  margin-top: 0.3rem;
  /* border: 1px solid salmon; */
  /* width: 5rem; */
  /* height: 3.65rem; */
}

.lbform div {
  margin-bottom: 10px;
  font-size: 0.3rem;
  /* color: #ffffff; */
}

.lbform div input {
  width: 3rem;
  height: 0.6rem;
  outline-style: none;
  /* background: url(../../assets/img/modal/inputbg.png); */
  background-size: 100% 100%;
  text-align: center;
}

.codestyle {
  width: 20% !important;
  border-radius: 30% !important;
  /* background: url(../../assets/img/modal/inputbgsec.png) no-repeat !important; */
  background-size: 100% 100% !important;
}

.sendcode {
  color: #857777;
  border-radius: 20px;
  border: 1px solid #857777;
  cursor: pointer;
  padding: 2px 3px;
}

.codenumber {
  width: 30px !important;
  border-radius: 20px;
  border: 1px solid #857777;
  color: #857777;
  padding: 2px 8px;
  text-align: center;
}

.gbsbutbox {
  /* border: 1px solid red; */
  width: 4.5rem;
  /* height: 0.4rem; */
}

.gbsbut2 {
  color: #ffffff;
  cursor: pointer;
  /* margin-left: 1.7rem; */
  width: 3rem;
  height: 1.3rem;
  transform: translateY(-0.08rem);
  background: url(@/assets/img/ok.png);
  background-size: 100% 100%;
}

.gbsbut2:hover {
  color: #ffffff;
  cursor: pointer;
  /* margin-left: 1.7rem; */
  width: 3rem;
  height: 1.3rem;
  transform: translateY(-0.09rem);
  background: url(@/assets/img/okhover.png);
  background-size: 100% 100%;
}

.mask {
  position: fixed;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  background: rgba(0, 0, 0, 0.7);
}

.tbagestyle {
  /* border: 1px solid red; */
  height: 16rem;
  width: 20.3333rem;
  overflow: hidden;
  position: absolute;
  top: 60%;
  left: 0;
  right: 0;
  margin: auto;
  transform: translateY(-50%);
  -webkit-transform: translateY(-50%);
  background: url(@/assets/img/modalbg.png) no-repeat;
  background-size: 100% 100%;

}

.yusuccessmodal {
  height: 4rem;
  width: 6.3333rem;
  overflow: hidden;
  position: absolute;
  top: 60%;
  left: 0;
  right: 0;
  margin: auto;
  transform: translateY(-50%);
  -webkit-transform: translateY(-50%);
  background: url(@/assets/img/modalsuccess.png) no-repeat;
  background-size: 100% 100%;
}

.gbstyel {
  cursor: pointer;
  margin-top: 0.5rem;
  margin-left: 6.6rem;
  width: 0.8rem;
  height: 0.8rem;
  background-image: url(@/assets/img/gb.png);
  background-size: 100% 100%;
}

.gbstyelsec {
  cursor: pointer;
  margin-top: 0.4rem;
  margin-left: 4.8rem;
  width: 0.8rem;
  height: 0.8rem;
  background-image: url(@/assets/img/gb.png);
  background-size: 100% 100%;
}
</style>
